package magics
{
	public class MagicSpriteCache
	{
		public function MagicSpriteCache()
		{
			_spriteCache = new Vector.<MagicSprite>();
		}
		
		public static function get instance():MagicSpriteCache
		{
			if(_instance == null)
				_instance = new MagicSpriteCache();
			return _instance;
		}
		
		
		public function getSprite():MagicSprite
		{
			if(_spriteCache.length == 0)	
			{
				return new MagicSprite();
			}
			else
			{
				return _spriteCache.pop();
			}
		}
		
		public function restoreSprite(sprite:MagicSprite):void
		{
			sprite.clear();
			_spriteCache.push(sprite);
		}
		
		
		private var _spriteCache:Vector.<MagicSprite>;
		private static var _instance:MagicSpriteCache;
	}
}